Class ExtensionMethodsString
Provides a set of extension methods dedicated to strings.
public static class ExtensionMethodsString
- Inheritance
-
ExtensionMethodsString
- Inherited Members
Methods (60)
Aggregate(IEnumerable<string>, string)
Aggregate string in this seq, with the string separator between each strings.
public static string Aggregate(this IEnumerable<string> seq, string separator)
Parameters
seqIEnumerable<string>The sequence of strings to aggregate.
separatorstringThe separator string in between each string aggregated.
Returns
ContainsAll(string, string, string, string, string, string, StringComparison)
Gets a value indicating whether this string contains all of the strings specified.
public static bool ContainsAll(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the string that must be contained by
thisString.str1stringOne of the string that must be contained by
thisString.str2stringOne of the string that must be contained by
thisString.str3stringOne of the string that must be contained by
thisString.str4stringOne of the string that must be contained by
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsAll(string, string, string, string, string, StringComparison)
Gets a value indicating whether this string contains all of the strings specified.
public static bool ContainsAll(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the string that must be contained by
thisString.str1stringOne of the string that must be contained by
thisString.str2stringOne of the string that must be contained by
thisString.str3stringOne of the string that must be contained by
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsAll(string, string, string, string, StringComparison)
Gets a value indicating whether this string contains all of the strings specified.
public static bool ContainsAll(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the string that must be contained by
thisString.str1stringOne of the string that must be contained by
thisString.str2stringOne of the string that must be contained by
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsAll(string, string, string, StringComparison)
Gets a value indicating whether this string contains all of the strings specified.
public static bool ContainsAll(this string thisString, string str0, string str1, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the string that must be contained by
thisString.str1stringOne of the string that must be contained by
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsAll(string, string[], StringComparison)
Gets a value indicating whether this string contains all of the strings specified.
public static bool ContainsAll(this string thisString, string[] array, StringComparison stringComparison)
Parameters
thisStringstringThis string.
arraystring[]An array containing strings that must be contained by
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsAny(string, string, string)
Gets a value indicating whether this string contains any case sensitive of the strings specified.
public static bool ContainsAny(this string thisString, string str0, string str1)
Parameters
thisStringstringThis string.
str0stringOne of the string that might be contained by
thisString.str1stringOne of the string that might be contained by
thisString.
Returns
ContainsAny(string, string, string, string)
Gets a value indicating whether this string contains any case sensitive of the strings specified.
public static bool ContainsAny(this string thisString, string str0, string str1, string str2)
Parameters
thisStringstringThis string.
str0stringOne of the string that might be contained by
thisString.str1stringOne of the string that might be contained by
thisString.str2stringOne of the string that might be contained by
thisString.
Returns
ContainsAny(string, string, string, string, string)
Gets a value indicating whether this string contains any case sensitive of the strings specified.
public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3)
Parameters
thisStringstringThis string.
str0stringOne of the string that might be contained by
thisString.str1stringOne of the string that might be contained by
thisString.str2stringOne of the string that might be contained by
thisString.str3stringOne of the string that might be contained by
thisString.
Returns
ContainsAny(string, string, string, string, string, string)
Gets a value indicating whether this string contains any case sensitive of the strings specified.
public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3, string str4)
Parameters
thisStringstringThis string.
str0stringOne of the string that might be contained by
thisString.str1stringOne of the string that might be contained by
thisString.str2stringOne of the string that might be contained by
thisString.str3stringOne of the string that might be contained by
thisString.str4stringOne of the string that might be contained by
thisString.
Returns
ContainsAny(string, string, string, string, string, string, StringComparison)
Gets a value indicating whether this string contains any of the strings specified.
public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the string that might be contained by
thisString.str1stringOne of the string that might be contained by
thisString.str2stringOne of the string that might be contained by
thisString.str3stringOne of the string that might be contained by
thisString.str4stringOne of the string that might be contained by
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsAny(string, string, string, string, string, string, params string[])
Gets a value indicating whether this string contains any case sensitive of the strings specified.
public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3, string str4, params string[] array)
Parameters
thisStringstringThis string.
str0stringOne of the string that might be contained by
thisString.str1stringOne of the string that might be contained by
thisString.str2stringOne of the string that might be contained by
thisString.str3stringOne of the string that might be contained by
thisString.str4stringOne of the string that might be contained by
thisString.arraystring[]An array of possible strings contained by
thisString.
Returns
Exceptions
- NullReferenceException
null string reference in
arraynot accepted.
ContainsAny(string, string, string, string, string, StringComparison)
Gets a value indicating whether this string contains any of the strings specified.
public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the string that might be contained by
thisString.str1stringOne of the string that might be contained by
thisString.str2stringOne of the string that might be contained by
thisString.str3stringOne of the string that might be contained by
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsAny(string, string, string, string, StringComparison)
Gets a value indicating whether this string contains any of the strings specified.
public static bool ContainsAny(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the string that might be contained by
thisString.str1stringOne of the string that might be contained by
thisString.str2stringOne of the string that might be contained by
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsAny(string, string, string, StringComparison)
Gets a value indicating whether this string contains any of the strings specified.
public static bool ContainsAny(this string thisString, string str0, string str1, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the string that might be contained by
thisString.str1stringOne of the string that might be contained by
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsAny(string, string[], StringComparison)
Gets a value indicating whether this string contains any of the strings specified.
public static bool ContainsAny(this string thisString, string[] array, StringComparison stringComparison)
Parameters
thisStringstringThis string.
arraystring[]An array containing possible values for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ContainsIgnoreCase(string, string)
Gets a value indicating whether this string contains the string specified, the comparison being case insensitive.
public static bool ContainsIgnoreCase(this string container, string contained)
Parameters
containerstringThis string that might contain
contained. If null, false is returned.containedstringThe string to seek in
container. If null, false is returned. If empty, true is returned.
Returns
- bool
true if
containedoccurs withincontainer, else false.
Remarks
The comparison relies on OrdinalIgnoreCase.
EndsWithAny(string, string, string)
Gets a value indicating whether this string ends with case sensitive any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.
Returns
EndsWithAny(string, string, string, string)
Gets a value indicating whether this string ends with case sensitive any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1, string str2)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.str2stringOne of the possible end string for
thisString.
Returns
EndsWithAny(string, string, string, string, string)
Gets a value indicating whether this string ends with case sensitive any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.str2stringOne of the possible end string for
thisString.str3stringOne of the possible end string for
thisString.
Returns
EndsWithAny(string, string, string, string, string, string)
Gets a value indicating whether this string ends with case sensitive any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.str2stringOne of the possible end string for
thisString.str3stringOne of the possible end string for
thisString.str4stringOne of the possible end string for
thisString.
Returns
EndsWithAny(string, string, string, string, string, string, string, string, string, StringComparison)
Gets a value indicating whether this string ends with any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, string str5, string str6, string str7, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.str2stringOne of the possible end string for
thisString.str3stringOne of the possible end string for
thisString.str4stringOne of the possible end string for
thisString.str5stringOne of the possible end string for
thisString.str6stringOne of the possible end string for
thisString.str7stringOne of the possible end string for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EndsWithAny(string, string, string, string, string, string, StringComparison)
Gets a value indicating whether this string ends with any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.str2stringOne of the possible end string for
thisString.str3stringOne of the possible end string for
thisString.str4stringOne of the possible end string for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EndsWithAny(string, string, string, string, string, string, params string[])
Gets a value indicating whether this string ends with case sensitive any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, params string[] array)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.str2stringOne of the possible end string for
thisString.str3stringOne of the possible end string for
thisString.str4stringOne of the possible end string for
thisString.arraystring[]An array containing possible end strings for
thisString.
Returns
Exceptions
- NullReferenceException
null string reference in
arraynot accepted.
EndsWithAny(string, string, string, string, string, StringComparison)
Gets a value indicating whether this string ends with any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.str2stringOne of the possible end string for
thisString.str3stringOne of the possible end string for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EndsWithAny(string, string, string, string, StringComparison)
Gets a value indicating whether this string ends with any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.str2stringOne of the possible end string for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EndsWithAny(string, string, string, StringComparison)
Gets a value indicating whether this string ends with any of the strings specified.
public static bool EndsWithAny(this string thisString, string str0, string str1, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible end string for
thisString.str1stringOne of the possible end string for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EndsWithAny(string, params string[])
Gets a value indicating whether this string ends with case sensitive any of the strings in array.
public static bool EndsWithAny(this string thisString, params string[] array)
Parameters
thisStringstringThis string.
arraystring[]An array containing possible end strings for
thisString.
Returns
Exceptions
- NullReferenceException
null string reference in
arraynot accepted.
EndsWithAny(string, string[], StringComparison)
Gets a value indicating whether this string ends with any of the strings specified.
public static bool EndsWithAny(this string thisString, string[] array, StringComparison stringComparison)
Parameters
thisStringstringThis string.
arraystring[]An array containing possible values for end of
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EqualsAny(string, HashSet<string>)
Gets a value indicating whether hashset contains the string thisString.
public static bool EqualsAny(this string thisString, HashSet<string> hashset)
Parameters
thisStringstringThis string.
hashsetHashSet<string>An hashset containing possible values for this
thisString.
Returns
Remarks
This EqualsAny(string, string, string) overload can be used to check the value of thisString against a large number of strings, in a constant time.
EqualsAny(string, string, string)
Gets a value indicating whether this string is equal case sensitive to any of the strings specified.
public static bool EqualsAny(this string thisString, string str0, string str1)
Parameters
thisStringstringThis string.
str0stringOne of the possible value for
thisString.str1stringOne of the possible value for
thisString.
Returns
EqualsAny(string, string, string, string)
Gets a value indicating whether this string is equal case sensitive to any of the strings specified.
public static bool EqualsAny(this string thisString, string str0, string str1, string str2)
Parameters
thisStringstringThis string.
str0stringOne of the possible value for
thisString.str1stringOne of the possible value for
thisString.str2stringOne of the possible value for
thisString.
Returns
EqualsAny(string, string, string, string, string)
Gets a value indicating whether this string is equal case sensitive to any of the strings specified.
public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3)
Parameters
thisStringstringThis string.
str0stringOne of the possible value for
thisString.str1stringOne of the possible value for
thisString.str2stringOne of the possible value for
thisString.str3stringOne of the possible value for
thisString.
Returns
EqualsAny(string, string, string, string, string, string)
Gets a value indicating whether this string is equal case sensitive to any of the strings specified.
public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3, string str4)
Parameters
thisStringstringThis string.
str0stringOne of the possible value for
thisString.str1stringOne of the possible value for
thisString.str2stringOne of the possible value for
thisString.str3stringOne of the possible value for
thisString.str4stringOne of the possible value for
thisString.
Returns
EqualsAny(string, string, string, string, string, string, StringComparison)
Gets a value indicating whether this string is equal to any of the strings specified.
public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible value for
thisString.str1stringOne of the possible value for
thisString.str2stringOne of the possible value for
thisString.str3stringOne of the possible value for
thisString.str4stringOne of the possible value for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EqualsAny(string, string, string, string, string, string, params string[])
Gets a value indicating whether this string is equal case sensitive to any of the strings specified.
public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3, string str4, params string[] array)
Parameters
thisStringstringThis string.
str0stringOne of the possible value for
thisString.str1stringOne of the possible value for
thisString.str2stringOne of the possible value for
thisString.str3stringOne of the possible value for
thisString.str4stringOne of the possible value for
thisString.arraystring[]An array containing possible values for
thisString.
Returns
EqualsAny(string, string, string, string, string, StringComparison)
Gets a value indicating whether this string is equal to any of the strings specified.
public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible value for
thisString.str1stringOne of the possible value for
thisString.str2stringOne of the possible value for
thisString.str3stringOne of the possible value for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EqualsAny(string, string, string, string, StringComparison)
Gets a value indicating whether this string is equal to any of the strings specified.
public static bool EqualsAny(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible value for
thisString.str1stringOne of the possible value for
thisString.str2stringOne of the possible value for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EqualsAny(string, string, string, StringComparison)
Gets a value indicating whether this string is equal to any of the strings specified.
public static bool EqualsAny(this string thisString, string str0, string str1, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible value for
thisString.str1stringOne of the possible value for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
EqualsAny(string, string[])
Gets a value indicating whether this string is equal case sensitive to any of the strings specified.
public static bool EqualsAny(this string thisString, string[] array)
Parameters
Returns
EqualsAny(string, string[], StringComparison)
Gets a value indicating whether this string is equal to any of the strings specified.
public static bool EqualsAny(this string thisString, string[] array, StringComparison stringComparison)
Parameters
thisStringstringThis string.
arraystring[]An array containing possible values for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
FirstCharToUpper(string)
Return word with first char as upper case.
public static string FirstCharToUpper(this string word)
Parameters
wordstringThe word to get first char as upper case.
Returns
Get4BytesHashCodeFast(string)
Get a 4 bytes string hash code, case-sensitive.
public static uint Get4BytesHashCodeFast(this string thisString)
Parameters
thisStringstringThe string to get hash code for.
Returns
Remarks
This method is about 4 times more performant than StringComparer.OrdinalIgnoreCase.GetHashCode(str).
It processes characters two by two by using pointers.
Get8BytesHashCodeFast(string)
Get a 8 bytes string hash code, case-sensitive.
public static ulong Get8BytesHashCodeFast(this string thisString)
Parameters
thisStringstringThe string to get hash code for.
Returns
GetNullOrEmptyDescElseGetString(string)
If str is null, returns the string "null".
If str is empty, returns the string "empty".
Else return str.
public static string GetNullOrEmptyDescElseGetString(this string str)
Parameters
strstringThe string reference.
Returns
GetWords(string)
Get the words in a code identifier.
public static string[] GetWords(this string identifier)
Parameters
identifierstringThe code
identifier
Returns
- string[]
Remarks
Typically the identifier is the ICodeElement.SimpleName.
For a complete behavior description, see this method source code and tests here: https://stackoverflow.com/a/48185710/27194
IsNullOrEmpty(string)
Returns true if str is a null reference or an empty string.
public static bool IsNullOrEmpty(this string str)
Parameters
strstringThe string reference.
Returns
Remarks
An alternative to string.IsNullOrEmpty() with less characters.
StartsWithAny(string, string, string)
Gets a value indicating whether this string starts with case sensitive any of the strings specified.
public static bool StartsWithAny(this string thisString, string str0, string str1)
Parameters
thisStringstringThis string.
str0stringOne of the possible start string for
thisString.str1stringOne of the possible start string for
thisString.
Returns
StartsWithAny(string, string, string, string)
Gets a value indicating whether this string starts with case sensitive any of the strings specified.
public static bool StartsWithAny(this string thisString, string str0, string str1, string str2)
Parameters
thisStringstringThis string.
str0stringOne of the possible start string for
thisString.str1stringOne of the possible start string for
thisString.str2stringOne of the possible start string for
thisString.
Returns
StartsWithAny(string, string, string, string, string)
Gets a value indicating whether this string starts with case sensitive any of the strings specified.
public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3)
Parameters
thisStringstringThis string.
str0stringOne of the possible start string for
thisString.str1stringOne of the possible start string for
thisString.str2stringOne of the possible start string for
thisString.str3stringOne of the possible start string for
thisString.
Returns
StartsWithAny(string, string, string, string, string, string)
Gets a value indicating whether this string starts with case sensitive any of the strings specified.
public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4)
Parameters
thisStringstringThis string.
str0stringOne of the possible start string for
thisString.str1stringOne of the possible start string for
thisString.str2stringOne of the possible start string for
thisString.str3stringOne of the possible start string for
thisString.str4stringOne of the possible start string for
thisString.
Returns
StartsWithAny(string, string, string, string, string, string, StringComparison)
Gets a value indicating whether this string starts with any of the strings specified.
public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible start string for
thisString.str1stringOne of the possible start string for
thisString.str2stringOne of the possible start string for
thisString.str3stringOne of the possible start string for
thisString.str4stringOne of the possible start string for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
StartsWithAny(string, string, string, string, string, string, params string[])
Gets a value indicating whether this string starts with case sensitive any of the strings specified.
public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, params string[] array)
Parameters
thisStringstringThis string.
str0stringOne of the possible start string for
thisString.str1stringOne of the possible start string for
thisString.str2stringOne of the possible start string for
thisString.str3stringOne of the possible start string for
thisString.str4stringOne of the possible start string for
thisString.arraystring[]An array containing possible start strings for
thisString.
Returns
Exceptions
- NullReferenceException
null string reference in
arraynot accepted.
StartsWithAny(string, string, string, string, string, StringComparison)
Gets a value indicating whether this string starts with any of the strings specified.
public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible start string for
thisString.str1stringOne of the possible start string for
thisString.str2stringOne of the possible start string for
thisString.str3stringOne of the possible start string for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
StartsWithAny(string, string, string, string, StringComparison)
Gets a value indicating whether this string starts with any of the strings specified.
public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible start string for
thisString.str1stringOne of the possible start string for
thisString.str2stringOne of the possible start string for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
StartsWithAny(string, string, string, StringComparison)
Gets a value indicating whether this string starts with any of the strings specified.
public static bool StartsWithAny(this string thisString, string str0, string str1, StringComparison stringComparison)
Parameters
thisStringstringThis string.
str0stringOne of the possible start string for
thisString.str1stringOne of the possible start string for
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
StartsWithAny(string, params string[])
Gets a value indicating whether this string starts with case sensitive any of the strings in array.
public static bool StartsWithAny(this string thisString, params string[] array)
Parameters
thisStringstringThis string.
arraystring[]An array containing possible start strings for
thisString.
Returns
Exceptions
- NullReferenceException
null string reference in
arraynot accepted.
StartsWithAny(string, string[], StringComparison)
Gets a value indicating whether this string starts with any of the strings specified.
public static bool StartsWithAny(this string thisString, string[] array, StringComparison stringComparison)
Parameters
thisStringstringThis string.
arraystring[]An array containing possible values for start of
thisString.stringComparisonStringComparisonOne of the enumeration values that determines how this string is compared to value.
Returns
ToCompressedBase64Url(string)
Compresses this string into a compact token made only of the characters A-Z a-z 0-9 - _: its UTF-8 bytes (no BOM) are compressed with Deflate, then encoded in base64url (RFC 4648 §5) without padding.
public static string ToCompressedBase64Url(this string thisString)
Parameters
thisStringstringThis string, can be empty.
Returns
- string
The compressed base64url token, empty when this string is empty.
Remarks
The token needs no quoting or escaping on any command line, shell or operating system — quotes, line breaks and non-ASCII characters of this string included. Decode it with TryDecompressFromBase64Url(string, out string). The output is always encoded, even when it is longer than this string.
TryDecompressFromBase64Url(string, out string)
Decompresses a token produced by ToCompressedBase64Url(string) back into the original string.
public static bool TryDecompressFromBase64Url(this string thisString, out string decoded)
Parameters
thisStringstringThe compressed base64url token, can be empty.
decodedstringThe original string, empty when the method returns false.
Returns
- bool
true if this token has been decoded, else false.
Remarks
Never throws: a token holding a character outside A-Z a-z 0-9 - _, truncated, not Deflate-compressed or not decoding to valid UTF-8 makes the method return false.